import Cookies from 'js-cookie'

const TokenKey = 'flysee_kanban_token'
const RefTokenKey = 'kanban_RefTokenKey'

export function getToken() {
  if(Cookies.get(TokenKey)){
    return Cookies.get(TokenKey)
  }else{
    return localStorage.getItem('TokenKey')
  }
  
}

export function setToken(token) {
  localStorage.setItem('TokenKey', token)
  return Cookies.set(TokenKey, token)
}

export function getRefToken(reftoken) {
  if(Cookies.get(RefTokenKey)){
    return Cookies.get(RefTokenKey)
  }else{
    return localStorage.getItem('RefTokenKey')
  }
  
}

export function setRefToken(reftoken) {
  localStorage.setItem('RefTokenKey', reftoken)
  return Cookies.set(RefTokenKey, reftoken)
}

export function removeToken() {
  localStorage.removeItem('TokenKey')
  localStorage.removeItem('RefTokenKey')
  return Cookies.remove(TokenKey)
}
